﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.ComponentModel.DataAnnotations.Schema;
using System.Data.Entity.ModelConfiguration;
using Iacym.Entities;

namespace Iacym.Repository.Mapping
{
    public class CELULAMap:EntityTypeConfiguration<CELULA>
    {
        public CELULAMap()
        {
            // Primary Key
            this.HasKey(t => t.Id);

            // Properties
            this.Property(t => t.Id)
                .HasDatabaseGeneratedOption(DatabaseGeneratedOption.Identity);

            this.Property(t => t.Descripcion)
                .IsRequired()
                .HasMaxLength(50);

            // Table & Column Mappings
            this.ToTable("CELULA");
            this.Property(t => t.Id).HasColumnName("Id");
            this.Property(t => t.Descripcion).HasColumnName("Descripcion");
            this.Property(t => t.MinisterioId).HasColumnName("MinisterioId");

            // Relationships
            this.HasRequired(t => t.MINISTERIO)
                .WithMany(t => t.CELULAs)
                .HasForeignKey(d => d.MinisterioId)
                .WillCascadeOnDelete(false);
        }
    }
}
